package com.zq.ribbon.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * Created by zhouquan on 2017/10/27.
 */
@RestController
public class ConsumerController {

    @Autowired
    private RestTemplate template;

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String zqconsumer() {
        return template.getForEntity("http://ZQSERVICE/user", String.class).getBody();
    }

    @RequestMapping(value = "/user/{id}", method = RequestMethod.DELETE)
    public String delete(@PathVariable Integer id) {
        return template.getForEntity("http://ZQSERVICE/user/" + id, String.class).getBody();
    }
}
